package com.taxshare.seller.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.entity.DocumentInfoDetailEntity;
import com.taxshare.seller.entity.DocumentInfoEntity;
import com.taxshare.seller.service.DocumentInfoService;
import com.taxshare.seller.service.InvoicedService;
import com.taxshare.seller.view.dto.CancelInvoiceDTO;
import com.taxshare.seller.view.dto.DocumentInfoDTO;
import com.taxshare.seller.view.vo.DocumentInfoReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author YANG
 * @date 2021/5/17
 */
@RestController
@RequestMapping("/documentInfo")
@Api(tags = "同步明源单据信息")
public class DocumentInfoController {

    @Autowired
    DocumentInfoService documentInfoService;

    @Autowired
    InvoicedService invoicedService;

    @ApiOperation(value = "同步明源单据信息", notes = "明源接口")
    @PostMapping("/syncDocument")
    public Response syncDocument(@RequestBody DocumentInfoDTO documentInfoDTO) {
        return documentInfoService.syncDocument(documentInfoDTO);
    }

    @ApiOperation(value = "明源发票作废红冲", notes = "明源接口")
    @PostMapping("/invoiceCancel")
    public Response invoiceCancel(@RequestBody CancelInvoiceDTO cancelInvoiceDTO) {
        return documentInfoService.invoiceCancel(cancelInvoiceDTO);
    }

    @PostMapping("/query")
    @ApiOperation(value = "订单列表", notes = "同步明源单据信息")
    public Response<IPage<DocumentInfoEntity>> queryDocument(@RequestBody PageRequest<DocumentInfoReqVO> query) {
        return documentInfoService.queryDocument(query);
    }

    @PostMapping("/queryDetail")
    @ApiOperation(value = "订单明细查询", notes = "同步明源单据信息")
    public Response<List<DocumentInfoDetailEntity>> queryDetail(@RequestParam String docId) {
        return documentInfoService.queryDetail(docId);
    }

    @ApiOperation(value = "生成预制发票", notes = "生成预制发票")
    @PostMapping("/precastInvoices")
    public Response precastInvoices(@RequestBody List<String> orderIds) {
        return documentInfoService.makeInvoice(orderIds);
    }

   /* @ApiOperation(value = "同步明源项目信息", notes = "明源接口")
    @GetMapping("/syncProject")
    public Response syncProject() {
        return documentInfoService.syncProject();
    }*/
}
